// 网络请求记录类型
export interface HttpRequest {
  id: string;
  url: string;
  method: string;
  headers: Record<string, string>;
  params: Record<string, string>;
  cookies: Record<string, string>;
  body: string;
  timestamp: number;
  clientHttpVersion: string;    // 客户端HTTP版本
  remoteHttpVersion?: string;   // 远程服务器HTTP版本
  tlsVersion?: string;          // TLS版本
  clientIp: string;
  remoteIp: string;
}

// 网络响应记录类型
export interface HttpResponse {
  id: string;
  requestId: string;
  statusCode: number;
  headers: Record<string, string>;
  cookies: Record<string, string>;
  body: string;
  bodySize: number;
  timestamp: number;
  remoteHttpVersion: string;  // 远程服务器HTTP版本
  tlsVersion?: string;        // TLS版本
}

// 完整的HTTP交互记录
export interface HttpTransaction {
  id: string;
  request: HttpRequest;
  response?: HttpResponse;
  duration?: number;
  createdAt: number;
}

// 规则配置类型
export interface Rule {
  id: string;
  name: string;
  description?: string;
  enabled: boolean;
  conditions: RuleCondition[];
  actions: RuleAction[];
  createdAt: number;
  updatedAt: number;
}

// 规则条件类型
export interface RuleCondition {
  type?: 'url_contains' | 'url_matches' | 'method_equals' | 'header_contains' | 'status_code_equals';
  field?: string;
  value: string;
  operator?: 'equals' | 'contains' | 'matches' | 'starts_with' | 'ends_with';
}

// 规则行为类型
export interface RuleAction {
  type: 'script' | 'log' | 'block' | 'modify_request' | 'modify_response';
  script?: string;
  enabled?: boolean;
}

// 代理配置类型
export interface ProxyConfig {
  enabled: boolean;
  port: number;
  httpsPort: number;
  interceptHttps: boolean;
}

// WebSocket消息类型
export interface WebSocketMessage {
  type: 'transaction' | 'rule_matched' | 'proxy_status' | 'error' | 'connection' | 'pong' | 'records_cleared';
  data: any;
  timestamp: number;
}

// 请求体格式类型
export type BodyFormat = 'text' | 'json' | 'hex' | 'xml' | 'javascript' | 'messagepack';

// 显示模式类型
export type ViewMode = 'headers' | 'params' | 'cookies' | 'raw' | 'body';

// 表格列类型
export interface TableColumn {
  key: string;
  title: string;
  width?: number;
  align?: 'left' | 'center' | 'right';
  render?: (row: any) => any;
}

// API响应类型
export interface ApiResponse<T = any> {
  data: T;
  total?: number;
  success?: boolean;
  message?: string;
  error?: string;
} 